﻿<Window x:Class="PTK_PSD_Browser.Views.Windows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:usercontrols="clr-namespace:PTK_PSD_Browser.Views.UserControls"
        xmlns:local="clr-namespace:PTK_PSD_Browser" 
        xmlns:viewmodels="clr-namespace:PTK_PSD_Browser.Core.ViewModels;assembly=PTK-PSD-Browser.Core"
        mc:Ignorable="d"
        Title="ПТК ПСД - Обозреватель отчетности" Height="450" Width="800">
    <Window.DataContext>
        <viewmodels:MainViewModel/>
    </Window.DataContext>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="Файл">
                <MenuItem Header="Выход"/>
            </MenuItem>
            <MenuItem Header="Вид">
                <MenuItem Header="Обновить"/>
                <Separator/>
                <MenuItem Header="Сортировать по коду" IsChecked="True"/>
                <MenuItem Header="Сортировать по названию"/>
                <Separator/>
                <MenuItem Header="Очистить кэш"/>
            </MenuItem>
            <MenuItem Header="Период">
                <MenuItem x:Name="DateNow" Header="Сегодня" Click="Period_Click"/>
                <MenuItem x:Name="Date1Day" Header="Вчера" Click="Period_Click"/>
                <MenuItem x:Name="Date4Days" Header="4 дня" Click="Period_Click"/>
                <MenuItem x:Name="Date1Week" Header="Неделя" Click="Period_Click"/>
                <Separator/>
                <MenuItem x:Name="Date1" Header="За дату" Click="DateSwitch_Click" IsCheckable="True" IsChecked="True"/>
                <MenuItem x:Name="Date2" Header="За период" Click="DateSwitch_Click" IsCheckable="True"/>
            </MenuItem>
            <MenuItem Header="Сервис">
                <Separator/>
                <MenuItem Header="Добавить..."/>
            </MenuItem>
            <MenuItem Header="Справка">
                <MenuItem Header="О программе..."/>
            </MenuItem>
        </Menu>
        <ToolBar DockPanel.Dock="Top" >
            <ComboBox x:Name="TitleList" Width="250" ItemsSource="{Binding Path=TitleObjects}" 
                      SelectedValue="{Binding Path=PostFilterObject.PostType, Mode=OneWayToSource}"
                      SelectedValuePath="PostType"
                      Margin="2,0,2,0" SelectedIndex="0" SelectionChanged="TitleList_SelectionChanged">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=PostDescription}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <DatePicker x:Name="DateBegin" SelectedDate="{Binding Path=PostFilterObject.DateBegin}"
                        DisplayDateEnd="{x:Static sys:DateTime.Now}"
                        FirstDayOfWeek="Monday" Margin="2,0,2,0" BorderThickness="0,0,0,0" VerticalContentAlignment="Center"/>
            <DatePicker x:Name="DateEnd" SelectedDate="{Binding Path=PostFilterObject.DateEnd}" 
                        DisplayDateEnd="{x:Static sys:DateTime.Now}"
                        FirstDayOfWeek="Monday" Margin="2,0,2,0" BorderThickness="0,0,0,0" VerticalContentAlignment="Center"/>
            <Button x:Name="Refresh" Content="&#x5B;" FontFamily="Wingdings" FontSize="18" ToolTip="Обновить" Click="Refresh_Click" Margin="2,0,2,0" Width="50"/>
        </ToolBar>
        <StatusBar DockPanel.Dock="Bottom">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem Margin="5,0">
                <TextBlock x:Name="Status" Text="Готово"/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="1">
                <ProgressBar x:Name="Progress" Height="10" Width="100"/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="2" Margin="5,0">
                <TextBlock x:Name="UserName" Text="{Binding Path=UserName}"/>
            </StatusBarItem>
            <StatusBarItem Grid.Column="3">
                <ResizeGrip/>
            </StatusBarItem>
        </StatusBar>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*"/>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <ListView x:Name="PostList" ItemsSource="{Binding Path=PostObjects}" SelectionMode="Single" 
                      SelectedValue="{Binding Path=FileName}"
                      SelectedValuePath="Filename" SelectionChanged="PostList_SelectionChanged">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Куда">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock FontFamily="Wingdings" FontSize="18" Text="{Binding Path=Arrow}"/>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding Path=Filetype}">Тип</GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding Path=Posttype}">Содержимое</GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding Path=Dt, StringFormat={}{0:dd.MM.yy HH:mm}}" >Получено</GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding Path=Filename}">Файл</GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding Path=Error}">Код ошибки</GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
            <GridSplitter Grid.Column="1" ResizeDirection="Columns" VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="3"/>
            <ScrollViewer Grid.Column="2" VerticalScrollBarVisibility="Auto">
                <usercontrols:PostViewControl x:Name="PostView"/>
            </ScrollViewer>
        </Grid>
    </DockPanel>
</Window>
